package com.dadibadi.core.work.controller;

import com.dadibadi.core.work.qo.WorkInfoIdQO;
import com.dadibadi.core.work.service.WorkInfoService;
import com.dadibadi.core.work.vo.WorkInfoListVO;
import com.venusoft.developer.common.result.CommonResult;
import com.venusoft.developer.common.result.ICommonResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 通过用户id查找作品
 */
@RestController
@RequestMapping("/work")
@Slf4j
@Tag(name = "api/用户信息", description = "")
public class ApiWorkInfoGetByUser {
    @Resource
    WorkInfoService workInfoService;

    @PostMapping("/api-work-info-user")
    @Operation(summary = "查询用户作品", description = "")
    @ApiResponses(value = {@ApiResponse(responseCode = "200", content = {@Content(schema = @Schema(implementation = WorkInfoListVO.class), mediaType = "application/json")})})
    public ICommonResult exec(
            @RequestBody @Parameter(required = true) @Validated WorkInfoIdQO qo,
            @RequestHeader(required = false) String platform,
            @RequestHeader(required = false) String version,
            HttpServletRequest request) {
        List<WorkInfoListVO> result = workInfoService.getWorkInfoByUser(qo);
        return new CommonResult<>(result);
    }
}
